import { Module } from 'vuex'
import { rootState } from '../index'
import * as BaseTypes from '../base-type'
export interface LowCodeState {
  contentJson: any,
  selectedWidget: any
}
const state : LowCodeState = {
  contentJson: {},
  selectedWidget: {}
}
const getters = {
    selectWidget: (state: LowCodeState) : any => state.selectedWidget,
    contentJson: (state: LowCodeState) : any => state.contentJson
  }
const mutations = {
  [BaseTypes.SET_SELECTEDWIDGET]: (state: LowCodeState, payload: any) => {
    if (payload) {
      state.selectedWidget = payload
    }
  },
  [BaseTypes.SET_CONTENTJSON]: (state: LowCodeState, payload:any) => {
    if (payload) {
      state.contentJson = payload
    }
  }
}
const lowCode : Module<LowCodeState, rootState> = {
  namespaced: true,
  state,
  getters,
  mutations
}
export default lowCode
